# coding=utf-8

from common.MyBluePrint import MyBluePrint
from common.UrlManager import UrlManager
from flask import redirect

route_admin = MyBluePrint('admin_page', __name__ )
route_web = MyBluePrint('web_page', __name__ )
route_api = MyBluePrint('api_page', __name__ )
route = MyBluePrint('page', __name__)
route_static = MyBluePrint('static', __name__)
route_upload = MyBluePrint('upload', __name__)


@route.route("/")
def run_index():
    return "welcome to the index page"

# @route_web.route("/")
# def index():
#     resp_data = {
#         'data': {
#             'site': {
#                 'today': 0,
#                 'month': 0
#             },
#             'customer': {
#                 'today': 0,
#                 'total': 0,
#                 'month': 0,
#             },
#             'book': {
#                 'today': 0,
#                 'month': 0
#             },
#             'strategy': {
#                 'today': 0,
#                 'month': 0
#             },
#         }
#     }
#
#     now = datetime.datetime.now()
#     date_before_30days = now + datetime.timedelta(days=-30)
#     date_before_yest = now + datetime.timedelta(days=-1)
#     date_from = get_format_date(date=date_before_30days, format="%Y-%m-%d")
#     date_to = get_format_date(date=date_before_yest, format="%Y-%m-%d")
#
#     list = StatDailySite.query.filter(StatDailySite.date >= date_from) \
#         .filter(StatDailySite.date <= date_to).order_by(StatDailySite.id.asc()).all()
#     data = resp_data['data']
#     if list:
#         for item in list:
#             data['site']['month'] += item.pay_money
#             data['customer']['month'] += item.new_vip_count
#             data['book']['month'] += item.book_order_count
#             data['strategy']['month'] += item.strategy_order_count
#             if get_format_date(date=item.date, format="%Y-%m-%d") == date_to:
#                 data['site']['today'] = item.pay_money
#                 data['customer']['total'] = item.vip_count
#                 data['customer']['today'] = item.new_vip_count
#                 data['book']['today'] = item.book_order_count
#                 data['strategy']['today'] = item.strategy_order_count
#
#     return ops_render("index/index.html", context=resp_data)

@route_api.route("/")
def api_index():
    return "Api V1.0~~"
